package com.wangp.mywrite.s_juc.concurrtent_tools;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;

import java.util.concurrent.CountDownLatch;

/**
 * @author tooStronger
 * @date 2023/5/16
 */
@Slf4j
public class CountDownLatchTest {

    private static final CountDownLatch LATCH = new CountDownLatch(3);

    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 3; i++) {
            new Thread(()->{
                log.info("开始执行");
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                }
                LATCH.countDown();
            }).start();
        }
        log.info("主线程wait");
        LATCH.await();
        log.info("主线程结束");
    }
}
